<?php

namespace App\Models;

use Spatie\Permission\Models\Role as BaseRole;

use Illuminate\Database\Eloquent\SoftDeletes;
use  App\Rules\HasPermissions;


/**
 * Class Role
 * @package App\Models
 * @version November 14, 2017, 3:24 am UTC
 *
 * @property string name
 * @property string guard
 */
class Role extends BaseRole
{
    use SoftDeletes;

    public $connection="mysql";

    public $table = 'roles';


    protected $dates = ['deleted_at'];


    public $fillable = [
        'name',
        'guard_name'
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'name' => 'string'
    ];

    /**
     * A role may be given various permissions.
     */
    public function menus()
    {
         return $this->belongsToMany(
            Menu::class,
            'role_has_menu',
            'role_id',
             'menu_id',
            'id'
        );
    }
     /**
     * A role may be given various permissions.
     */
    public function parks()
    {
         return $this->belongsToMany(
            ParkInfo::class,
            'role_has_park',
            'role_id',
             'park_code',
            'id'
        );
    }


}
